package com.example.demo.hadoop.reduce.service;

import com.example.demo.hadoop.utils.HdfsUtils;
import com.example.demo.hadoop.utils.ReduceJobsUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class MapReduceService {
    private static final String OUTPUT_PATH = "/output";

    @Autowired
    HdfsUtils hdfsUtils;

    public void wordCount(String jobName, String inputPath) throws Exception {
        if (StringUtils.isEmpty(jobName) || StringUtils.isEmpty(inputPath)) {
            throw new Exception("参数错误");
        }
        String outputPath = OUTPUT_PATH + "/" + jobName;
        if (hdfsUtils.existFile(outputPath)) {
            hdfsUtils.deleteFile(outputPath);
        }
    }
}
